package com.mlethe.android.demo.dialog;

import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;

import android.graphics.Color;
import android.os.Build;
import android.os.Bundle;
import android.view.View;
import android.view.WindowInsets;
import android.view.WindowInsetsAnimation;

import com.mlethe.android.demo.R;
import com.mlethe.library.dialog.DialogFragment;
import com.mlethe.library.immersionbar.BarHide;
import com.mlethe.library.immersionbar.ImmersionBar;
import com.mlethe.library.utils.app.StatusBarUtil;

import java.util.List;

public class MainDialogActivity extends AppCompatActivity implements View.OnClickListener {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
//        getWindow().setDecorFitsSystemWindows(false);
        setContentView(R.layout.activity_dialog_main);
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
            WindowInsetsAnimation.Callback callback = new WindowInsetsAnimation.Callback(WindowInsetsAnimation.Callback.DISPATCH_MODE_CONTINUE_ON_SUBTREE) {
                @NonNull
                @Override
                public WindowInsets onProgress(@NonNull WindowInsets windowInsets, @NonNull List<WindowInsetsAnimation> list) {
                    return null;
                }
            };
            getWindow().getDecorView().setWindowInsetsAnimationCallback(callback);
        }
        ImmersionBar.with(this).hideBar(BarHide.FLAG_IMMERSIVE_BAR)
                .autoDarkModeEnable(true)
//                .statusBarColorEnabled(true)
//                .statusBarColor("#36000000")
//                .statusBarColorInt(Color.CYAN)
//                .statusBarColorInt(Color.TRANSPARENT, Color.TRANSPARENT,0.3f)
//                .navigationBarColor("#36000000")
                .init();
//        StatusBarUtil.transparent(this);
        findViewById(R.id.dialog_btn).setOnClickListener(this);
        findViewById(R.id.dialog_btn2).setOnClickListener(this);
        findViewById(R.id.dialog_btn3).setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        int id = v.getId();
        if (id == R.id.dialog_btn) {
            new TestOneDialog().showAllowingStateLoss(getSupportFragmentManager());
        } else if (id == R.id.dialog_btn2) {
            /*View view = LayoutInflater.from(this).inflate(R.layout.layout_dialog, null, false);
            new androidx.appcompat.app.AlertDialog.Builder(this)
                    .setView(view)
                    .show();*/
            new TestDialog().setState(DialogFragment.FLAG_FULL_HIDE_BAR).showAllowingStateLoss(getSupportFragmentManager());
        } else if (id == R.id.dialog_btn3) {
            new TestSecondDialog()
                    .setNoTitle(true)
                    .setCancelableOnTouchOutside(false)
                    .showAllowingStateLoss(getSupportFragmentManager());
        }
    }
}
